package cn.dlc.com.order.controller;

import cn.dlc.com.order.entity.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("{id}")
    public Product findById(@PathVariable("id") String id) {
        System.out.println("order");
        Product product = restTemplate.getForObject("http://localhost:8001/product/" + id, Product.class);
        return product;
    }
}
